﻿# 设置Boost相关路径变量
$BOOST_INCLUDE_ROOT = "D:\Work\boost-1.88.0"
$BOOST_LIB_X64_RELEASE_ROOT = "D:\Work\boost-1.88.0\stage\x64\Release\lib"
$BOOST_LIB_X64_DEBUG_ROOT = "D:\Work\boost-1.88.0\stage\x64\Debug\lib"
$BOOST_LIB_WIN32_RELEASE_ROOT = "D:\Work\boost-1.88.0\stage\Win32\Release\lib"
$BOOST_LIB_WIN32_DEBUG_ROOT = "D:\Work\boost-1.88.0\stage\Win32\Debug\lib"

# 创建输出目录结构（不存在则创建）
$outputDirs = @(
    ".\lib",
    ".\lib\x64",
    ".\lib\Win32",
    ".\lib\x64\Debug",
    ".\lib\x64\Release",
    ".\lib\Win32\Debug",
    ".\lib\Win32\Release",
    ".\include",
    ".\include\hiredis",
    ".\include\hiredis\adapters"
)

foreach ($dir in $outputDirs) {
    if (-not (Test-Path -Path $dir)) {
        New-Item -Path $dir -ItemType Directory | Out-Null
    }
}

# 复制Boost头文件（递归复制所有内容）
# 注：/NFL /NDL 对应PowerShell的静默模式
robocopy "$BOOST_INCLUDE_ROOT\boost" ".\include\boost" /E /COPYALL /R:1 /W:1 /NFL /NDL

# 定义要复制的库文件列表（使用数组简化重复代码）
$x64DebugLibs = @(
    "boost_filesystem-vc143-mt-gd-x64-1_88.*",
    "boost_container-vc143-mt-gd-x64-1_88.*",
    "boost_log-vc143-mt-gd-x64-1_88.*",
    "boost_log_setup-vc143-mt-gd-x64-1_88.*",
    "boost_thread-vc143-mt-gd-x64-1_88.*",
    "boost_atomic-vc143-mt-gd-x64-1_88.*",
    "boost_json-vc143-mt-gd-x64-1_88.*",
    "boost_locale-vc143-mt-gd-x64-1_88.*",
    "boost_chrono-vc143-mt-gd-x64-1_88.*",
    "boost_stacktrace_windbg-vc143-mt-gd-x64-1_88.*"
)

$x64ReleaseLibs = @(
    "boost_filesystem-vc143-mt-x64-1_88.*",
    "boost_container-vc143-mt-x64-1_88.*",
    "boost_log-vc143-mt-x64-1_88.*",
    "boost_log_setup-vc143-mt-x64-1_88.*",
    "boost_thread-vc143-mt-x64-1_88.*",
    "boost_atomic-vc143-mt-x64-1_88.*",
    "boost_json-vc143-mt-x64-1_88.*",
    "boost_locale-vc143-mt-x64-1_88.*",
    "boost_chrono-vc143-mt-x64-1_88.*",
    "boost_stacktrace_windbg-vc143-mt-x64-1_88.*"
)

$win32DebugLibs = @(
    "boost_filesystem-vc143-mt-gd-x32-1_88.*",
    "boost_container-vc143-mt-gd-x32-1_88.*",
    "boost_log-vc143-mt-gd-x32-1_88.*",
    "boost_log_setup-vc143-mt-gd-x32-1_88.*",
    "boost_thread-vc143-mt-gd-x32-1_88.*",
    "boost_atomic-vc143-mt-gd-x32-1_88.*",
    "boost_json-vc143-mt-gd-x32-1_88.*",
    "boost_locale-vc143-mt-gd-x32-1_88.*",
    "boost_chrono-vc143-mt-gd-x32-1_88.*",
    "boost_stacktrace_windbg-vc143-mt-gd-x32-1_88.*"
)

$win32ReleaseLibs = @(
    "boost_filesystem-vc143-mt-x32-1_88.*",
    "boost_container-vc143-mt-x32-1_88.*",
    "boost_log-vc143-mt-x32-1_88.*",
    "boost_log_setup-vc143-mt-x32-1_88.*",
    "boost_thread-vc143-mt-x32-1_88.*",
    "boost_atomic-vc143-mt-x32-1_88.*",
    "boost_json-vc143-mt-x32-1_88.*",
    "boost_locale-vc143-mt-x32-1_88.*",
    "boost_chrono-vc143-mt-x32-1_88.*",
    "boost_stacktrace_windbg-vc143-mt-x32-1_88.*"
)

# 复制64位Debug库
foreach ($lib in $x64DebugLibs) {
    Copy-Item -Path (Join-Path $BOOST_LIB_X64_DEBUG_ROOT $lib) -Destination ".\lib\x64\Debug" -ErrorAction SilentlyContinue
}

# 复制64位Release库
foreach ($lib in $x64ReleaseLibs) {
    Copy-Item -Path (Join-Path $BOOST_LIB_X64_RELEASE_ROOT $lib) -Destination ".\lib\x64\Release" -ErrorAction SilentlyContinue
}

# 复制32位Debug库
foreach ($lib in $win32DebugLibs) {
    Copy-Item -Path (Join-Path $BOOST_LIB_WIN32_DEBUG_ROOT $lib) -Destination ".\lib\Win32\Debug" -ErrorAction SilentlyContinue
}

# 复制32位Release库
foreach ($lib in $win32ReleaseLibs) {
    Copy-Item -Path (Join-Path $BOOST_LIB_WIN32_RELEASE_ROOT $lib) -Destination ".\lib\Win32\Release" -ErrorAction SilentlyContinue
}